import 'package:mybase/base/tool/file/FFPath.dart';
import 'package:package_info/package_info.dart';

class FFPackage {
  /// The app name. `CFBundleDisplayName` on iOS, `application/label` on Android.
  final String appName;

  // CFBundleDisplayName2
  final String appName2;

  /// The package name. `bundleIdentifier` on iOS, `getPackageName` on Android.
  final String packageName;

  /// The package version. `CFBundleShortVersionString` on iOS, `versionName` on Android.
  final String version;

  /// The build number. `CFBundleVersion` on iOS, `versionCode` on Android.
  final String buildNumber;

  final String phonePath;

  FFPackage({
    required this.appName,
    required this.appName2,
    required this.packageName,
    required this.version,
    required this.buildNumber,
    required this.phonePath,
  });

  static Future<FFPackage> getPackage() async {
    PackageInfo packageInfo = await PackageInfo.fromPlatform();
    String phonePath = await FFPath.getPhoneLocalPath();
    return FFPackage(
      appName: packageInfo.appName,
      appName2: packageInfo.appName2,
      packageName: packageInfo.packageName,
      version: packageInfo.version,
      buildNumber: packageInfo.buildNumber,
      phonePath: phonePath,
    );
  }
}
